using System;

namespace Xajhzwb.Components.Data
{
	public sealed class DataAccessFactory
	{
		private DataAccessFactory(){}
		private static DatabaseProperty defaultDatabaseProperty;
		public static DatabaseProperty DefaultDatabaseProperty
		{
			get{return defaultDatabaseProperty;}
			set{defaultDatabaseProperty=value;}
		}

		public static DataAccess CreateDataAccess(DatabaseProperty pp)
		{
			DataAccess dataAccess;
			switch(pp.DatabaseType)
			{
				case(DatabaseType.MSSQLServer):
					dataAccess = new MsSqlDataAccess(pp.ConnectionString);
					break;
				case(DatabaseType.Oracle):
					dataAccess = new OracleDataAccess(pp.ConnectionString);
					break;
				case(DatabaseType.OleDBSupported):
					dataAccess = new OleDbDataAccess(pp.ConnectionString);
					break;
				default:
					dataAccess=new MsSqlDataAccess(pp.ConnectionString);
					break;
			}
			return dataAccess;
		}

		public static DataAccess CreateDataAccess()
		{
			return CreateDataAccess(defaultDatabaseProperty);
		}
	}

}

